﻿@{
    List<Group> groups = ViewBag.groups;
    int page = ViewBag.page;
    int pageNumber = ViewBag.pageNumber;
    string keyword = ViewBag.keyword;
    ViewBag.Title = keyword + " - 搜索群组";
    Layout = "~/Views/Shared/_layout.cshtml";
}
@section sidebar {
    @Html.Partial("_sidebar")
}
<ul class="list-group">
    <li class="list-group-item">
        <div class="row">
            <div class="col-md-6">群组名</div>
            <div class="col-md-2">拥有者</div>
            <div class="col-md-2">人数</div>
            <div class="col-md-2">加入</div>
        </div>
    </li>
    @foreach (var g in groups)
    {
        <li class="list-group-item">
            <div class="row">
                <div class="col-md-6">@g.group_name</div>
                <div class="col-md-2">@UserView.GetUserById((int)g.owner_uid).name</div>
                <div class="col-md-2">@g.number</div>
                <div class="col-md-2">
                    @if (g.allow_join)
                {
                        <a class="btn btn-sm btn-primary es-exam-list-enter" href="#" onclick="join_group(@g.gid)">加入群组</a>
                    }
                    else
                    {
                        <a class="btn btn-sm btn-primary es-exam-list-enter disabled">加入群组</a>
                    }
                </div>
            </div>
        </li>
    }
</ul>
<br />
<div class="es-pager">
    @if (page > 1)
    {
        <a class="btn btn-sm btn-primary es-pager-previous" href="/Search/Groups/@(page - 1)?content=@keyword">上一页</a>
    }
    else
    {
        <a class="btn btn-sm btn-primary es-pager-previous disabled" href="#">上一页</a>
    }
    <div class="es-pager-num">第 @page 页</div>
    @if (page < pageNumber)
    {
        <a class="btn btn-sm btn-primary es-pager-next" href="/Search/Groups/@(page + 1)?content=@keyword">下一页</a>
    }
    else
    {
        <a class="btn btn-sm btn-primary es-pager-next disabled" href="#">下一页</a>
    }
</div>